/**
 * Simple warper for animate function
 * @param array options 
 * @auhtor Lukasz Tobra <torba.lukasz@gmail.com>
 */
 
$.fn.Animation = function(conf)
{
    var options = $.extend({},{
        duration: 2000,
        action: 'fadein',
        from: 'up',
        callback: null,
    },conf);
        
   
        
    if(options.action != null)
    {
    
        var Width = $(this).width();  // element width
        var Height = 500; // element height
        var Element = $(this);
        
        $(this).css({
            'position':'relative',
            'overflow':'hidden'
        });
        
        // Define animation type
        if(options.action == 'slide')
        {
            if(options.from == 'left')
            {
                $(this).width(0);
                param = {
                    'width': Width
                };
            }
            else if(options.from == 'right')
            {            
                $(this).css({'position':'absolute',
                    'left':Width,
                    'width': 0});
                param = {
                    'width': Width,
                    'left': 0,
                };               
            }
            else if(options.from == 'bottom')
            {                
                $(this).css({'position':'absolute',
                    'top': Height+1,
                    'height': 0});
                param = { 'top': 0,
                    'height': Height };
                
            }
            else if(options.from == 'top')
            {                 
                $(this).height(0);
                param = { 'height': Height };
            }else
            {
                if(typeof(callback) == "function")
                    {
                        callback(Element);
                    }
            };
        }
        else if(options.action == 'fadein')
        {
            $(this).css({'opacity': 0.0});
            param = { 'opacity': 1.0 };
        }
        
        // Call animation
        $(this).animate(param,{            
                'duration': options.duration,
                'complete': function(){
                    Element.css({
                            'overflow':'none',     
                            'position':'relative',
                        });                    
                    if(typeof(callback) == "function")
                    {
                        callback(Element);
                    }
                }
            });
            
     }
}